package 笔试.科大讯飞笔试.第一题地摊找零;

import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int[] nums=new int[5];
        for(int i=0;i<nums.length;i++)
        {
            nums[i]=in.nextInt();
        }
        int target=in.nextInt();
        int result=0;
        while (nums[4]!=0&&target>=100)
        {
            target-=100;
            nums[4]--;
            result++;
        }
        while (nums[3]!=0&&target>=50)
        {
            target-=50;
            nums[3]--;
            result++;
        }
        while (nums[2]!=0&&target>=10)
        {
            target-=10;
            nums[2]--;
            result++;
        }
        while (nums[1]!=0&&target>=5)
        {
            target-=5;
            nums[1]--;
            result++;
        }
        while (nums[0]!=0&&target>=1)
        {
            target-=1;
            nums[0]--;
            result++;
        }
        if (target==0)
            System.out.println(result);
        else
            System.out.println(-1);
    }
}
